﻿using System;
using System.Threading.Tasks;
using System.Windows.Forms;
using Hourglass.Qrobot.Displayers;
using Hourglass.Qrobot.States;

namespace Hourglass.Qrobot.Management
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            var context = new QQContext(new WattingForGetQRCodeState());
            context.Displayer = new PictureBoxDisplayer(this.pictureBox1);

            context.Process();
            Task.Run(() =>
            {
                while (true)
                {
                    context.Process();
                    if (context.HasException)
                    {
                        MessageBox.Show(context.Exception.Message);
                        break;
                    }
                }
            });
        }
    }
}
